package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.ZzxxExaminationFillingquestion;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.service.IZzxxExaminationFillingquestionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 填空题外键表Controller
 * 
 * @author ruoyi
 * @date 2022-06-20
 */
@RestController
@RequestMapping("/zzxx/fillingquestion")
public class ZzxxExaminationFillingquestionController extends BaseController
{
    @Autowired
    private IZzxxExaminationFillingquestionService zzxxExaminationFillingquestionService;

    /**
     * 查询填空题外键表列表
     */
    @PreAuthorize("@ss.hasPermi('zzxx:fillingquestion:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZzxxExaminationFillingquestion zzxxExaminationFillingquestion)
    {
        startPage();
        List<ZzxxExaminationFillingquestion> list = zzxxExaminationFillingquestionService.selectZzxxExaminationFillingquestionList(zzxxExaminationFillingquestion);
        return getDataTable(list);
    }

    /**
     * 导出填空题外键表列表
     */
    @PreAuthorize("@ss.hasPermi('zzxx:fillingquestion:export')")
    @Log(title = "填空题外键表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZzxxExaminationFillingquestion zzxxExaminationFillingquestion)
    {
        List<ZzxxExaminationFillingquestion> list = zzxxExaminationFillingquestionService.selectZzxxExaminationFillingquestionList(zzxxExaminationFillingquestion);
        ExcelUtil<ZzxxExaminationFillingquestion> util = new ExcelUtil<ZzxxExaminationFillingquestion>(ZzxxExaminationFillingquestion.class);
        util.exportExcel(response, list, "填空题外键表数据");
    }

    /**
     * 获取填空题外键表详细信息
     */
    @PreAuthorize("@ss.hasPermi('zzxx:fillingquestion:query')")
    @GetMapping(value = "/{examinationId}")
    public AjaxResult getInfo(@PathVariable("examinationId") Long examinationId)
    {
        return AjaxResult.success(zzxxExaminationFillingquestionService.selectZzxxExaminationFillingquestionByExaminationId(examinationId));
    }

    /**
     * 新增填空题外键表
     */
    @PreAuthorize("@ss.hasPermi('zzxx:fillingquestion:add')")
    @Log(title = "填空题外键表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZzxxExaminationFillingquestion zzxxExaminationFillingquestion)
    {
        return toAjax(zzxxExaminationFillingquestionService.insertZzxxExaminationFillingquestion(zzxxExaminationFillingquestion));
    }

    /**
     * 修改填空题外键表
     */
    @PreAuthorize("@ss.hasPermi('zzxx:fillingquestion:edit')")
    @Log(title = "填空题外键表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZzxxExaminationFillingquestion zzxxExaminationFillingquestion)
    {
        return toAjax(zzxxExaminationFillingquestionService.updateZzxxExaminationFillingquestion(zzxxExaminationFillingquestion));
    }

    /**
     * 删除填空题外键表
     */
    @PreAuthorize("@ss.hasPermi('zzxx:fillingquestion:remove')")
    @Log(title = "填空题外键表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{examinationIds}")
    public AjaxResult remove(@PathVariable Long[] examinationIds)
    {
        return toAjax(zzxxExaminationFillingquestionService.deleteZzxxExaminationFillingquestionByExaminationIds(examinationIds));
    }
}
